The goal of this paper is to give a geometric construction of the Bethe algebra (of Hamiltonians) of a Gaudin model associated to a simple Lie algebra. More precisely, in this paper a quantum integrable model is assigned to a weighted arrangement of affine hyperplanes. We show (under certain assumptions) that the algebra of Hamiltonians of the model is isomorphic to the algebra of functions on the critical set of the corresponding master function. For a discriminantal arrangement we show (under certain assumptions) that the symmetric part of the algebra of Hamiltonians is isomorphic to the Bethe algebra of the corresponding Gaudin model. It is expected that this correspondence holds in general (without the assumptions). As a byproduct of constructions we show that in a Gaudin model (associated to an arbitrary simple Lie algebra), the Bethe vector, corresponding to an isolated critical point of the master function, is nonzero.